#include "cxcontrolframe.h"
#include "ui_cxcontrolframe.h"
#include "cxglobal.h"
#include "cxmonsetdialog.h"
#include "cxdevicedialog.h"
#include "cxdbsetdialog.h"
#include "cxlocalsetdialog.h"
CxControlFrame::CxControlFrame(QWidget *parent) :
    QFrame(parent),
    ui(new Ui::CxControlFrame)
{
    ui->setupUi(this);
    connect(this,SIGNAL(sig_updateAll()),this,SLOT(slot_updateAll()),Qt::QueuedConnection);
    emit sig_updateAll();
}

CxControlFrame::~CxControlFrame()
{
    delete ui;
}

void CxControlFrame::on_pushButton_clicked()
{
    CxMonSetDialog dlg;
    dlg.exec();
}

void CxControlFrame::on_pushButton_2_clicked()
{
    CxDbSetDialog dlg;
    dlg.exec();
}

void CxControlFrame::on_pushButton_3_clicked()
{
    CxLocalSetDialog dlg;
    dlg.exec();
}

void CxControlFrame::on_pushButton_4_clicked()
{
    CxDeviceDialog dlg;
    dlg.exec();
}

void    CxControlFrame::slot_updateAll()
{
    CxGlobal gl;
    ui->lineEdit_channel1_addr->setText(QString::fromStdString(gl.getIpaddr(0)));
    ui->lineEdit_channel2_addr->setText(QString::fromStdString(gl.getIpaddr(1)));
    ui->lineEdit_channel3_addr->setText(QString::fromStdString(gl.getIpaddr(2)));
    ui->lineEdit_channel4_addr->setText(QString::fromStdString(gl.getIpaddr(3)));

    ui->lineEdit_database_type->setText(QString::fromStdString(gl.getdbType()));
    ui->lineEdit_database_addr->setText(QString::fromStdString(gl.getdbAddr()));
}
